package com.mf.morefun.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;

import com.mf.morefun.MoreFunApplication;
import com.mf.morefun.bean.EventMessageBean;

import org.greenrobot.eventbus.EventBus;

public class MusicPositionService extends Service implements Runnable{
    private Thread mThread;
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        mThread = new Thread(this);
        mThread.start();
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void run() {
        while (true) {
            try {
                if (MoreFunApplication.isOut){
                    break;
                }
                EventMessageBean eventMessageBean = new EventMessageBean();
                eventMessageBean.setNum(0);
                eventMessageBean.setType(3);
                eventMessageBean.setProgress(0);
                EventBus.getDefault().post(eventMessageBean);
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
